package com.imcode.sortdemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class UserApp {
    public static void main(String[] args) {
        List<User> list = new ArrayList<>();
        Collections.addAll(list,
                new User(200,"张三"),
                new User(100,"李四"),
                new User(20,"王五"),
                new User(3,"赵六"),
                new User(10,"田七")
        );
        for (User u: list) {
            System.out.println(u.getId() + " " + u.getUsername());
        }
        System.out.println("-------------------------");

        Collections.sort(list);

        for (User u: list) {
            System.out.println(u.getId() + " " + u.getUsername());
        }
    }
}
